<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <head th:include="common/common_head :: commonHead('系统日志管理')"></head>
</head>
<body class="auth-user">
<div class="layui-fluid">
    <div class="layui-row larryms-panel auth-user-add">
        <form class="layui-form" id="jobForm">
            <div class="layui-form-item">
                <label for="jobName" class="layui-form-label">
                    <span class="x-red">*</span>任务名称
                </label>
                <div class="layui-input-block">
                    <input type="hidden" id="id" name="id" th:value="${job?.id}"/>
                    <input type="text" id="jobName" name="jobName" lay-verify="jobName"
                           autocomplete="off" class="layui-input larry-input" th:value="${job?.jobName}"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="cron" class="layui-form-label">
                    <span class="x-red">*</span>表达式
                </label>
                <div class="layui-input-block">
                    <input type="text" id="cron" name="cron" lay-verify="cron" autocomplete="off"
                           class="layui-input larry-input" th:value="${job?.cron}"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="cron" class="layui-form-label">
                    <a href="http://cron.qqe2.com/" target="_blank"><span class="x-red">获取表达式</span></a>
                </label>
            </div>
            <!--<div class="layui-form-item">
                <label for="status" class="layui-form-label">
                    <span class="x-red">*</span>状态
                </label>
                <div class="layui-input-inline">
                    <input type="checkbox" name="status" id="status" lay-skin="switch"
                           lay-text="启用|停用" lay-filter="statusDemo"
                           th:attr="checked=${(job?.status == null or job?.status == 1) ? 'true' : 'false'}"/>
                </div>
            </div>-->
            <div class="layui-form-item">
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
                    <legend style="font-size:16px;">执行类要实现Job</legend>
                </fieldset>
            </div>
            <div class="layui-form-item">
                <label for="clazzPath" class="layui-form-label">
                    <span class="x-red">*</span>任务执行类
                </label>
                <div class="layui-input-block">
                    <input type="text" id="clazzPath" name="clazzPath" lay-verify="clazzPath"
                           autocomplete="off" class="layui-input larry-input" th:value="${job?.clazzPath}"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="jobDesc" class="layui-form-label">
                    <span class="x-red">*</span>任务描述
                </label>
                <div class="layui-input-block">
                    <input type="text" id="jobDesc" name="jobDesc" lay-verify="jobDesc" autocomplete="off"
                           class="layui-input larry-input" th:value="${job?.jobDesc}"/>
                </div>
            </div>
            <div  th:if="${param.detail == null}">
                <div class="larryms-layer-btn">
                    <a class="layui-btn layui-btn layui-btn-sm left" lay-submit=""
                       lay-filter="add" id="submit" th:attr="data-url=@{/system/job/save}">保存</a>
                    <a class="layui-btn layui-btn layui-btn-sm  layui-btn-danger" id="resetBtn">重置</a>
                    <a class="layui-btn layui-btn layui-btn-sm  layui-btn-primary" id="close">关闭</a>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript" th:src="@{/static/larryms/layui/layui.js}"/>
<script type="text/javascript" th:inline="javascript">/*<![CDATA[*/
var bathPath = /*[[@{/}]]*/ "/";
layui.config({
    version: ui.version,
    layertype:2,
    base: bathPath + 'static/larryms/',  //实际使用时，建议改成绝对路径
    rightMenu: "none" // false关闭，设置为custom时使用自定义，不使用默认menu
}).extend({
    larry:'js/base'
}).use(['larry', 'table'], function () {
    var $ = layui.$, larryms = layui.larryms, form = layui.form;
    //自定义验证规则
    form.verify({
        jobName: function (value) {
            if (value.trim() == "") {
                return "任务名称不能为空";
            }
        },
        cron: function (value) {
            if (value.trim() == "") {
                return "表达式不能为空";
            }
        },
        clazzPath: function (value) {
            if (value.trim() == "") {
                return "执行类不能为空";
            }
        }
    });

    var indexFre = parent.layer.getFrameIndex(window.name);
    $('#close').click(function () {
        parent.layer.close(indexFre);
    });
    $('#resetBtn').on('click', function() {
        $('#jobForm')[0].reset();
    });
    //监听提交
    form.on('submit(add)', function (data) {
        var url = $(this).data("url");
        $.post(url, data.field, function(res) {
            if (res.code == "success") {
                larryms.msg(res.desc);
                parent.table.reload('jobList', {});
                parent.layer.close(indexFre);
            }
        });
        return false;
    });
    form.render();
});
/*]]>*/</script>
</body>
</html>